package com.ias.agdis_r.util;

import android.content.Context;

import java.util.HashMap;

import com.ias.agdis_r.R;
import com.ias.agdis_r.bean.task.TaskServiceLabel;
import com.ias.agdis_r.manager.DataBaseManager;
import com.ias.agdis_r.manager.DataManager;

public class ServiceLabelUtil {
	
	//上报服务标注列表，用于保存上报服务标注消息的服务内容
	public final static HashMap<String,String> reportServiceContentMap = new HashMap<String,String>();

	private static Context context = DataBaseManager.getInstance().getContext();
	/**
	 * 修改对应TNB的服务标注内容
	 * @param _sTnb 任务号
	 * @param mknm 标注名称
	 * @param ctnt 标注内容
	 * @return
	 */
	public static String editIStandard(String tnb, String mki, String cnt) {	
		String alertMsg ="";
//		try {
			//变更标注信息的航班号
			String flno = DataManager.getInstance().getWorkTask(tnb).getTaskInfo().getFKE();
			
			HashMap<String, TaskServiceLabel> servicelabels = DataManager.getInstance().getWorkTask(tnb).getServiceLabelMap();
			
			TaskServiceLabel label = servicelabels.get(mki);
			
			if (label != null) {
				String tmp = label.getCTNT();
				if (cnt != null) { // 如果不是删除服务标注
					label.setCTNT(cnt);
					alertMsg = context.getString(R.string.flight) + flno + "\n\n"+context.getString(R.string.leftBracket) + tmp + context.getString(R.string.TRA_10)
							+ label.getCTNT() + context.getString(R.string.rightBracket);

				} else {
					servicelabels.remove(mki);
					alertMsg = context.getString(R.string.flight) + flno + "\n\n"+context.getString(R.string.leftBracket) + tmp + context.getString(R.string.delete2);

				}
			}
		
		return alertMsg;
	}
	
	/**
	 * 保存上报服务标注
	 */
	public static void saveReportServiceLabel(String ms,String content)
	{
		reportServiceContentMap.put(ms, content);
	}
	
	/**
	 * 获取已经上报的服务标注（获取后删除）
	 */
	public static String getReportServiceLabel(String ms)
	{
		String content = reportServiceContentMap.get(ms);
		reportServiceContentMap.remove(ms);		
		return content;
	}
	

	/**
	 * 清空上报服务标注列表
	 */
	public static void clearReportServiceLabel()
	{
		reportServiceContentMap.clear();
	}
}
